<% option explicit %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>OWASP Stinger For Classic ASP</title>
    <!-- Include stinger component -->
    <!-- #include virtual="/validation/stinger.asp" -->

    <!-- Some CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
    <% 
      'Declare validation class
  Dim validator
  set validator = new Stinger
  'Send Javascript Code for better user experience, pass form name as parameter
      response.write validator.getJavaScript ("myform")
    %>
</head>
<body>
    <div class="container">
        <h2>OWASP Stinger for Classic ASP - Demo Page</h2>
        <%	
        if Request.Item("loginbutton") <> "" then
	    Dim errors
	    'Perform Server Side Validation
	    set errors = validator.validate
		      ' display any errors found
		  if not errors is nothing then
		    if errors.count > 0 then
			        Response.Write "<div class='label label-warning'>Your request did not pass Stinger validation!</div>" 
			        Response.Write "<div class='alert alert-warning'>" 
			    Response.Write validator.format(errors)
			        Response.Write "</div>" 
		    else
			        Response.Write "<div class='alert alert-info'>Congratulations! Your request passed Stinger validation!</div>"
        end if
      end if
    end if
        %>
        <p class="lead">Please enter your credentials to log in:</p>
        <form id="myform" method="post" action="Default.asp" style="width:400px">
            <label for="username">Username: </label>
            <input type="text" class="form-control" name="username" id="username" placeholder="Enter Username">
            <label for="password">Password: </label>
            <input type="text" class="form-control" name="password" id="password">
            <input type="submit" onclick="return validate()" class="btn btn-default" id="loginbutton" name="loginbutton" value="Login" />
        </form>
    </div>
</body>
</html>
